package com.guhus.ec.controller.seller;

import com.guhus.ec.pojo.seller.Brand;
import com.guhus.ec.pojo.seller.Cate1;
import com.guhus.ec.pojo.seller.Cate2;
import com.guhus.ec.pojo.seller.Cate3;
import com.guhus.ec.service.seller.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class CategoryController {
    @Autowired
    CategoryService categoryService;

    @ResponseBody
    @RequestMapping("/selectCate1ById")
    public Cate1 selectCate1ById(Integer id) {
        return categoryService.selectCate1ById(id);
    }

    @ResponseBody
    @RequestMapping("/selectCate2ById")
    public Cate2 selectCate2ById(Integer id) {
        return categoryService.selectCate2ById(id);
    }

    @ResponseBody
    @RequestMapping("/selectCate3ById")
    public Cate3 selectCate3ById(@RequestParam(value = "id") Integer id) {
        return categoryService.selectCate3ById(id);
    }

    @ResponseBody
    @RequestMapping("/selectBrandById")
    public Cate3 selectBrandById(Integer id) {
        return categoryService.selectBrandById(id);
    }

    @ResponseBody
    @RequestMapping("/selectAllCate1s")
    public List<Cate1> selectAllCate1s() {
        return categoryService.selectAllCate1s();
    }

    @ResponseBody
    @RequestMapping("/selectAllCate2s")
    public List<Cate2> selectAllCate2s() {
        return categoryService.selectAllCate2s();
    }

    @ResponseBody
    @RequestMapping("/selectAllCate3s")
    public List<Cate3> selectAllCate3s() {
        return categoryService.selectAllCate3s();
    }

    @ResponseBody
    @RequestMapping("/selectAllBrands")
    public List<Brand> selectAllBrands() {
        return categoryService.selectAllBrands();
    }


    @ResponseBody
    @RequestMapping("/selectCate2ByPid")
    public List<Cate2> selectCate2ByPid(@RequestParam(value = "pid") Integer pid) {
        return categoryService.selectCate2ByPid(pid);
    }

    @ResponseBody
    @RequestMapping("/selectCate3ByPid")
    public List<Cate3> selectCate3ByPid(@RequestParam(value = "pid") Integer pid) {
        return categoryService.selectCate3ByPid(pid);
    }

    @ResponseBody
    @RequestMapping("/selectCate3ByBrandId")
    public Cate3 selectCate3ByBrandId(@RequestParam(value = "id") Integer id) {
        return categoryService.selectCate3ByBrandId(id);
    }

    @ResponseBody
    @RequestMapping("/selectAllBrandsByCate3Id")
    public List<Brand> selectAllBrandsByCate3Id(@RequestParam(value = "id") Integer id) {
        return categoryService.selectAllBrandsByCate3Id(id);
    }
}
